﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ModelLayer
{
    public class Activity
    {
        private string _name;
        private string _description;
        private List<ActivityRoom> _activityRooms;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        public List<ActivityRoom> ActivityRooms
        {
            get { return _activityRooms; }
            set { _activityRooms = value; }
        }

        public ActivityRoom NextActivityRoom
        {
            get { return GetNextActivityRoom(); }
        }

        public Activity()
        {
            _name = "";
            _description = "";
            _activityRooms = new List<ActivityRoom>();
        }

        public Activity(string name, string description)
        {
            _name = name;
            _description = description;
            _activityRooms = new List<ActivityRoom>();
        }

        private ActivityRoom GetNextActivityRoom()
        {
            ActivityRoom result = null;

            foreach (ActivityRoom item in _activityRooms)
            {
                if (item.StartDate > DateTime.Now)
                {
                    if (result != null)
                    {
                        if (item.StartDate < result.StartDate)
                            result = item;
                    }
                    else
                    {
                        result = item;
                    }
                }
            }

            return result;
        }
    }
}
